package game.worlds;

import game.data.EffectData;
import hx.display.MovieClip;

/**
 * 角色动作特效
 */
class RoleActionEffect extends GameEffect {
	private var __initAdvance = false;

	override function onCreate() {
		// 读取
		var actionData = this.role.assets.data.actions.get(this.id);
		__movieClip = new MovieClip();
		for (data in actionData.frames) {
			var name = data.name.split(":")[0];
			__movieClip.addFrame(this.role.assets.getBitmapData(data.name), 1 / actionData.fps, null, this.role.roleData.getOffestPoint(name));
		}
		var originData = new EffectData();
		originData.frames = actionData.frames.copy();
		originData.fps = actionData.fps;
		this.originData = originData;
		this.onTransform(0);
	}

	override function onUpdate(dt:Float) {
		super.onUpdate(dt);
		if (!__initAdvance) {
			this.__advance(0);
			__initAdvance = true;
		}
	}
}
